package dao.implementations.postgresql.Administrador;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import dao.implementations.DBBase;
import dao.interfaces.Administrador.IAdministrador;

public class AdministradorDB extends DBBase implements IAdministrador {

	public AdministradorDB(Connection connection){
		this.conn = connection;
	}
	
	@Override
	public int eliminarAdministrador(int rut) {
		PreparedStatement ps = null;
		int result = -1;
		
		String query = "DELETE FROM administrador WHERE rut_admin=?";
		
		try{
			ps = this.conn.prepareStatement(query);
			ps.setInt(1, rut);
			
			result = ps.executeUpdate();
		}
		catch (SQLException ex)
		{
			System.out.println("Error en la clase AdministradorDB -> eliminarAdministrador -> "+ ex.getMessage());
		}		
		return result;
	}

}
